package com.lhn.service.impl;

import com.lhn.entity.Order;
import com.lhn.mapper.OrderMapper;
import com.lhn.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author lhn
 * @date 2024-10-14 17:30
 */

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    OrderMapper orderMapper;

    @Override
    public void save(Order order) {
        Date date = new Date();
        order.setDate(date);
        orderMapper.save(order);
    }

    @Override
    public List<Order> findAll(int index, int limit) {
        return orderMapper.findAll(index, limit);
    }

    @Override
    public List<Order> findAllByUid(long uid, int index, int limit) {
        return orderMapper.findAllByUid(uid, index, limit);
    }

    @Override
    public int count() {
        return orderMapper.count();
    }

    @Override
    public int countByUid(long uid) {
        return orderMapper.countByUid(uid);
    }

    @Override
    public List<Order> findAllByState(int state, int index, int limit) {
        return orderMapper.findAllByState(state, index, limit);
    }

    @Override
    public int countByState(int state) {
        return orderMapper.countByState(state);
    }

    @Override
    public void updateState(long id, int state) {
        orderMapper.updateState(id, state);
    }

    @Override
    public List<Order> findAllState(int index, int limit) {
        return orderMapper.findAllState(index, limit);
    }
}
